/*     */ package com.qmsk.business.info.etpscale.controller;
/*     */ 
/*     */ import com.qmsk.business.info.etpscale.dao.EtpscaleDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"etpsCale"})
/*     */ public class EtpscaleController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(EtpscaleController.class);
/*     */ 
/*     */   @Autowired
/*     */   private EtpscaleDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  49 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  51 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  74 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 125 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 127 */       String[] strParams = id.split(",");
/* 128 */       int nResult = this.dao.deleteParams(strParams);
/* 129 */       DbConnection.commit();
/* 130 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 131 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 132 */         response);
/*     */     } catch (Exception e) {
/* 134 */       DbConnection.rollback();
/* 135 */       logger.error(e);
/* 136 */       ResponseUtils.setErrorMsgResponse(
/* 137 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 138 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 154 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 156 */       int nResult = 0;
/* 157 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 158 */       if (p != null) {
/* 159 */         nResult = this.dao.applyUpdates(p);
/* 160 */         if (nResult > 0)
/* 161 */           DbConnection.commit();
/*     */         else {
/* 163 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 167 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 168 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 169 */         response);
/*     */     } catch (Exception e) {
/* 171 */       DbConnection.rollback();
/* 172 */       logger.error(e);
/* 173 */       ResponseUtils.setErrorMsgResponse(
/* 174 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + 
/* 175 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.etpscale.controller.EtpscaleController
 * JD-Core Version:    0.5.3
 */